package com.hljx.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.hljx.dto.DateDTO;
import com.hljx.entity.*;
import com.hljx.mapper.gy.GYItemMapper;
import com.hljx.mapper.sys.*;
import com.hljx.service.EtlItemDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hljx.utils.ThreadPoolProxy;
import com.hljx.utils.TimeUtils;
import com.hljx.vo.ProjectTargetBillDeptVO;
import com.hljx.vo.ProjectTargetExeDeptVO;
import com.hljx.vo.ProjectTargetResultVO;
import com.hljx.vo.ProjectTargetVO;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Collectors;

/**
 * <p>
 * 数据抽取明细表 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2023-10-27
 */
@Service
public class EtlItemDetailServiceImpl extends ServiceImpl<EtlItemDetailMapper, EtlItemDetail> implements EtlItemDetailService {


    @Autowired
    private WorkloadTargetAdministrationMapper workloadTargetAdministrationMapper;
    @Autowired
    private EtlItemSummaryMapper etlItemSummaryMapper;
    @Autowired
    private WorkloadSummaryMapper  workloadSummaryMapper;
    @Autowired
    private  EtlItemConfigMapper  etlItemConfigMapper;
    @Autowired
    private GYItemMapper gyItemMapper;



    @Override
    @Transactional(rollbackFor = Exception.class)
    public void dataCleaning(DateDTO dto) {

        DateDTO dateDTO = updateInformation(dto);
        List<EtlItemDetail> etlItemDetailList = new ArrayList<>();
        // 数据汇总
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllByDate(dateDTO));
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture1 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllByFeeitemList(dateDTO));
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture2 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllByFeeitemListC(dateDTO));
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture3 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllByXT(dateDTO));
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture4 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllBySH(dateDTO));
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture5 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllByCRY(dateDTO));
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture6 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllByZYS(dateDTO));
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture7 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllByZZJH(dateDTO));
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture8 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllByGY(dateDTO));
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture9 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllByNJSH(dateDTO));
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture10 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllBySHRZ(dateDTO));

        CompletableFuture<List<EtlItemDetail>> listCompletableFuture11 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllByYZC(dateDTO));
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture12 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllByYZD(dateDTO));
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture13 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllByMZGZL(dateDTO));
        CompletableFuture<List<EtlItemDetail>> listCompletableFuture14 =
                CompletableFuture.supplyAsync(() -> baseMapper.selectAllByMZGZL2(dateDTO));
        CompletableFuture.allOf(listCompletableFuture, listCompletableFuture1,
                listCompletableFuture2,
                listCompletableFuture3,
                listCompletableFuture4, listCompletableFuture5,
                listCompletableFuture6 ,listCompletableFuture7 ,
                listCompletableFuture8,listCompletableFuture9
                ,
                listCompletableFuture10,
                listCompletableFuture11,listCompletableFuture12
                ,listCompletableFuture13
                ,listCompletableFuture14
        ).join();

        try {
            List<EtlItemDetail> etlItemDetails = listCompletableFuture.get();
            List<EtlItemDetail> etlItemDetails2 = listCompletableFuture1.get();
            etlItemDetailList.addAll(etlItemDetails);
            etlItemDetailList.addAll(etlItemDetails2);
            etlItemDetailList.addAll(listCompletableFuture2.get());
            etlItemDetailList.addAll(listCompletableFuture3.get());
            etlItemDetailList.addAll(listCompletableFuture4.get());
            etlItemDetailList.addAll(listCompletableFuture5.get());
            etlItemDetailList.addAll(listCompletableFuture6.get());
            etlItemDetailList.addAll(listCompletableFuture7.get());
            etlItemDetailList.addAll(listCompletableFuture8.get());
            etlItemDetailList.addAll(listCompletableFuture9.get());
            etlItemDetailList.addAll(listCompletableFuture10.get());
            etlItemDetailList.addAll(listCompletableFuture11.get());
            etlItemDetailList.addAll(listCompletableFuture12.get());
            etlItemDetailList.addAll(listCompletableFuture13.get());
            etlItemDetailList.addAll(listCompletableFuture14.get());

        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException(e);
        }
        baseMapper.deleteAll(dateDTO.getPeriod());


        int total2 = etlItemDetailList.size();//为防止插入字符超过最大数,分批插入
        int fromIndex2 = 0;
        List<EtlItemDetail> insertList2 = new ArrayList<>();
        for (int i = 0; i < etlItemDetailList.size(); i++) {
            EtlItemDetail item = etlItemDetailList.get(i);
            fromIndex2++;
            insertList2.add(item);
            if (fromIndex2 % 1000 == 0 && fromIndex2 <= total2) {
                baseMapper.insertBatch(insertList2, dateDTO.getPeriod());
                insertList2 = new ArrayList<>();
            }
        }
        if (CollectionUtils.isNotEmpty(insertList2)) {
            baseMapper.insertBatch(insertList2, dateDTO.getPeriod());
        }


    }



    @Override
    @Transactional(rollbackFor = Exception.class)
    public void dataStatistics(DateDTO dateDTO) {
        List<EtlItemDetail> etlItemDetailList1 = baseMapper.selectAllByPeriod(dateDTO.getPeriod());
        List<EtlItemConfig> period = etlItemConfigMapper.selectList(new QueryWrapper<EtlItemConfig>().eq("period", dateDTO.getPeriod()));
        List<EtlItemDetail> etlItemDetailList =new ArrayList<>();
        List<String> collect1 = period.stream().map(s -> s.getProjectCode()).collect(Collectors.toList());
        List<EtlItemDetail> collect2 = etlItemDetailList1.stream().filter(s -> !collect1.contains(s.getItemCode()) && !s.getWorkloadTypeCode().equals("105")).collect(Collectors.toList());
        etlItemDetailList.addAll(collect2);
        for (EtlItemConfig etlItemConfig : period) {
            List<String> split = List.of(etlItemConfig.getDeptCodeList().split(","));
            List<EtlItemDetail> collect = etlItemDetailList1.stream().filter(s -> split.contains(s.getDeptCode()) && s.getItemCode().equals(etlItemConfig.getProjectCode()) && s.getWorkloadTypeCode().equals(etlItemConfig.getWorkloadTypeCode())).collect(Collectors.toList());
            if (!collect.isEmpty()){
            etlItemDetailList.addAll(collect);}
        }



        List<ProjectTargetVO> projectTargetVOS = workloadTargetAdministrationMapper.searchAllByTime(dateDTO.getPeriod());

        List<EtlItemSummary> etlItemSummaries = new ArrayList<>();

        for (ProjectTargetVO projectTargetVO : projectTargetVOS) {


            List<String> list = projectTargetVO.getProjectTargetBillDeptVOS().stream()
                    .map(ProjectTargetBillDeptVO::getBillDeptCode).toList();

            List<String> list1 = projectTargetVO.getProjectTargetExeDeptVOS().stream()
                    .map(ProjectTargetExeDeptVO::getExeDeptCode).toList();


            if (StringUtils.isNotEmpty(projectTargetVO.getDeptCode())) {

                List<EtlItemDetail> collect = etlItemDetailList.stream().filter(s -> s.getDeptCode().equals(projectTargetVO.getDeptCode()) &&
                        s.getItemCode().equals(projectTargetVO.getProjectCode())).toList();
                if (collect.size() > 0) {
                    for (EtlItemDetail etlItemDetail : collect) {
                        if (list.size() > 0) {
                            if (list.contains(etlItemDetail.getBillDeptCode())) {
                                if (list1.size() > 0) {
                                    if (list1.contains(etlItemDetail.getExeDeptCode())) {
                                        EtlItemSummary etlItemSummary = new EtlItemSummary();
                                        BeanUtils.copyProperties(projectTargetVO, etlItemSummary);
                                        etlItemSummary.setPionts(projectTargetVO.getCount());
                                        etlItemSummary.setCounts(etlItemDetail.getAmount());
                                        etlItemSummary.setAmount(projectTargetVO.getCount().multiply(etlItemDetail.getAmount()));
                                        etlItemSummary.setWorkloadTypeCode(etlItemDetail.getWorkloadTypeCode());
                                        etlItemSummary.setWorkloadTypeName(etlItemDetail.getWorkloadTypeName());
                                        etlItemSummaries.add(etlItemSummary);
                                    }

                                } else {
                                    EtlItemSummary etlItemSummary = new EtlItemSummary();
                                    BeanUtils.copyProperties(projectTargetVO, etlItemSummary);
                                    etlItemSummary.setPionts(projectTargetVO.getCount());
                                    etlItemSummary.setCounts(etlItemDetail.getAmount());
                                    etlItemSummary.setAmount(projectTargetVO.getCount().multiply(etlItemDetail.getAmount()));
                                    etlItemSummary.setWorkloadTypeCode(etlItemDetail.getWorkloadTypeCode());
                                    etlItemSummary.setWorkloadTypeName(etlItemDetail.getWorkloadTypeName());
                                    etlItemSummaries.add(etlItemSummary);
                                }


                            }
                        } else {
                            if (list1.size() > 0) {
                                if (list1.contains(etlItemDetail.getExeDeptCode())) {
                                    EtlItemSummary etlItemSummary = new EtlItemSummary();
                                    BeanUtils.copyProperties(projectTargetVO, etlItemSummary);
                                    etlItemSummary.setPionts(projectTargetVO.getCount());
                                    etlItemSummary.setCounts(etlItemDetail.getAmount());
                                    etlItemSummary.setAmount(projectTargetVO.getCount().multiply(etlItemDetail.getAmount()));
                                    etlItemSummary.setWorkloadTypeCode(etlItemDetail.getWorkloadTypeCode());
                                    etlItemSummary.setWorkloadTypeName(etlItemDetail.getWorkloadTypeName());
                                    etlItemSummaries.add(etlItemSummary);
                                }

                            } else {
                                EtlItemSummary etlItemSummary = new EtlItemSummary();
                                BeanUtils.copyProperties(projectTargetVO, etlItemSummary);
                                etlItemSummary.setPionts(projectTargetVO.getCount());
                                etlItemSummary.setCounts(etlItemDetail.getAmount());
                                etlItemSummary.setAmount(projectTargetVO.getCount().multiply(etlItemDetail.getAmount()));
                                etlItemSummary.setWorkloadTypeCode(etlItemDetail.getWorkloadTypeCode());
                                etlItemSummary.setWorkloadTypeName(etlItemDetail.getWorkloadTypeName());
                                etlItemSummaries.add(etlItemSummary);
                            }
                        }

                    }
                }

            } else {

                List<EtlItemDetail> collect = etlItemDetailList.stream().filter(s ->
                        s.getItemCode().equals(projectTargetVO.getProjectCode())).toList();

                if (collect.size() > 0) {
                    for (EtlItemDetail etlItemDetail : collect) {
                        if (list.size() > 0) {
                            if (list.contains(etlItemDetail.getBillDeptCode())) {
                                if (list1.size() > 0) {
                                    if (list1.contains(etlItemDetail.getExeDeptCode())) {
                                        EtlItemSummary etlItemSummary = new EtlItemSummary();
                                        BeanUtils.copyProperties(projectTargetVO, etlItemSummary);
                                        etlItemSummary.setPionts(projectTargetVO.getCount());
                                        etlItemSummary.setCounts(etlItemDetail.getAmount());
                                        etlItemSummary.setAmount(projectTargetVO.getCount().multiply(etlItemDetail.getAmount()));
                                        etlItemSummary.setDeptCode(etlItemDetail.getDeptCode());
                                        etlItemSummary.setDeptName(etlItemDetail.getDeptName());
                                        etlItemSummary.setWorkloadTypeCode(etlItemDetail.getWorkloadTypeCode());
                                        etlItemSummary.setWorkloadTypeName(etlItemDetail.getWorkloadTypeName());
                                        etlItemSummaries.add(etlItemSummary);
                                    }
                                } else {
                                    EtlItemSummary etlItemSummary = new EtlItemSummary();
                                    BeanUtils.copyProperties(projectTargetVO, etlItemSummary);
                                    etlItemSummary.setPionts(projectTargetVO.getCount());
                                    etlItemSummary.setCounts(etlItemDetail.getAmount());
                                    etlItemSummary.setAmount(projectTargetVO.getCount().multiply(etlItemDetail.getAmount()));
                                    etlItemSummary.setDeptCode(etlItemDetail.getDeptCode());
                                    etlItemSummary.setDeptName(etlItemDetail.getDeptName());
                                    etlItemSummary.setWorkloadTypeCode(etlItemDetail.getWorkloadTypeCode());
                                    etlItemSummary.setWorkloadTypeName(etlItemDetail.getWorkloadTypeName());
                                    etlItemSummaries.add(etlItemSummary);
                                }

                            }
                        } else {
                            if (list1.size() > 0) {
                                if (list1.contains(etlItemDetail.getExeDeptCode())) {
                                    EtlItemSummary etlItemSummary = new EtlItemSummary();
                                    BeanUtils.copyProperties(projectTargetVO, etlItemSummary);
                                    etlItemSummary.setPionts(projectTargetVO.getCount());
                                    etlItemSummary.setCounts(etlItemDetail.getAmount());
                                    etlItemSummary.setAmount(projectTargetVO.getCount().multiply(etlItemDetail.getAmount()));
                                    etlItemSummary.setDeptCode(etlItemDetail.getDeptCode());
                                    etlItemSummary.setDeptName(etlItemDetail.getDeptName());
                                    etlItemSummary.setWorkloadTypeCode(etlItemDetail.getWorkloadTypeCode());
                                    etlItemSummary.setWorkloadTypeName(etlItemDetail.getWorkloadTypeName());
                                    etlItemSummaries.add(etlItemSummary);
                                }

                            } else {
                                EtlItemSummary etlItemSummary = new EtlItemSummary();
                                BeanUtils.copyProperties(projectTargetVO, etlItemSummary);
                                etlItemSummary.setPionts(projectTargetVO.getCount());
                                etlItemSummary.setCounts(etlItemDetail.getAmount());
                                etlItemSummary.setAmount(projectTargetVO.getCount().multiply(etlItemDetail.getAmount()));
                                etlItemSummary.setDeptCode(etlItemDetail.getDeptCode());
                                etlItemSummary.setDeptName(etlItemDetail.getDeptName());
                                etlItemSummary.setWorkloadTypeCode(etlItemDetail.getWorkloadTypeCode());
                                etlItemSummary.setWorkloadTypeName(etlItemDetail.getWorkloadTypeName());
                                etlItemSummaries.add(etlItemSummary);
                            }
                        }

                    }


                }

            }

        }
        System.out.println(etlItemSummaries);
        List<EtlItemSummary> etlItemSummaryList = new ArrayList<>();

        Map<String, List<EtlItemSummary>> collect = etlItemSummaries.stream().collect(Collectors.groupingBy(s -> (s.getDeptCode() + s.getWorkloadCode() + s.getWorkloadTypeCode()+s.getProjectCode())));

        for (String s : collect.keySet()) {
            List<EtlItemSummary> etlItemSummaries1 = collect.get(s);
            EtlItemSummary etlItemSummary = new EtlItemSummary();
            BeanUtils.copyProperties(etlItemSummaries1.get(0),etlItemSummary);
            BigDecimal amount = BigDecimal.ZERO;
            BigDecimal counts = BigDecimal.ZERO;
            for (EtlItemSummary itemSummary : etlItemSummaries1) {
                if (itemSummary.getAmount() != null) {
                    amount = amount.add(itemSummary.getAmount());
                }
                if (itemSummary.getCounts()!=null){
                    counts = counts.add(itemSummary.getCounts());
                }
            }
            etlItemSummary.setAmount(amount.stripTrailingZeros());
            etlItemSummary.setCounts(counts.stripTrailingZeros());
            etlItemSummaryList.add(etlItemSummary);
        }

        etlItemSummaryMapper.deleteAll(dateDTO.getPeriod());
        etlItemSummaryMapper.insertBatch(etlItemSummaryList,dateDTO.getPeriod());



    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void dataSummary(DateDTO dateDTO) {
        List<WorkloadSummary> workloadSummaries = etlItemSummaryMapper.listEtlItemSummaryByPeriod(dateDTO);
        workloadSummaryMapper.deleteAll(dateDTO.getPeriod());
        workloadSummaryMapper.insertBatch(workloadSummaries,dateDTO.getPeriod());

    }

    @Autowired
    private JobLauncher jobLauncher;
    @Autowired
    private AssessmentCycleMapper  assessmentCycleMapper;

    @Autowired
    @Qualifier("ifFeeitemListJob")
    private Job ifFeeitemListJob;

    @Autowired
    @Qualifier("undrugDetailJob")
    private Job undrugDetailJob;

    @Autowired
    @Qualifier("ipMomDodJob")
    private Job ipMomDodJob;

    @Autowired
    @Qualifier("ipMonMexJob")
    private Job ipMonMexJob;

    @Autowired
    @Qualifier("rEmployeeJob")
    private Job rEmployeeJob;

    @Autowired
    @Qualifier("opApplyJob")
    private Job  opApplyJob;

    @Autowired
    @Qualifier("mrmsdymrJob")
    private Job  mrmsdymrJob;

    @Autowired
    @Qualifier("rDepartmentJob")
    private Job rDepartmentJob;
    @Autowired
    @Qualifier("cpoeProjectDischargeExeJob")
    private  Job cpoeProjectDischargeExeJob;

    @Autowired
    @Qualifier("OpRecordJob")
    private  Job OpRecordJob;

    @Autowired
    @Qualifier("MedOperationMasterJob")
    private Job MedOperationMasterJob;





    @Override
    @Transactional(rollbackFor = Exception.class)
    public void dataDecimation(DateDTO dateDTO) throws JobInstanceAlreadyCompleteException, JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {

        AssessmentCycle assessmentCycle = assessmentCycleMapper.selectById(dateDTO.getId());
        String startTime = assessmentCycle.getStartDate().toString();
        String endTime = assessmentCycle.getEndDate().toString();
        String startDate = TimeUtils.getLocalDateStartString(assessmentCycle.getStartDate());
        String endDate = TimeUtils.getLocalDateEndString(assessmentCycle.getEndDate());
        String start = TimeUtils.getLocalDateToString(assessmentCycle.getStartDate());
        String end = TimeUtils.getLocalDateToString(assessmentCycle.getEndDate().plusDays(1));
        String  splitTableName =assessmentCycle.getYear().toString()+assessmentCycle.getTimes().toString();

        JobParameters jobParameters = new JobParametersBuilder()
                .addLong("time",System.currentTimeMillis())
                .addString("year",assessmentCycle.getYear().toString() )
                .addString("times",assessmentCycle.getTimes().toString())
                .addString("startDate", startDate)
                .addString("endDate",endDate)
                .addString("start",start )
                .addString("end",end)
                .addString("startTime",startTime )
                .addString("endTime",endTime)
                .addString("splitTableName",splitTableName)
                .toJobParameters();

        ThreadPoolProxy threadPoolProxy = new ThreadPoolProxy();
        ThreadPoolExecutor executor = threadPoolProxy.threadPoolExecutor();
        List<CompletableFuture<Void>> completableFutureList = new ArrayList<>();
        CompletableFuture<Void> completableFuture = CompletableFuture.runAsync(() -> {
            try {
                jobLauncher.run(ifFeeitemListJob, jobParameters);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, executor);
        completableFutureList.add(completableFuture);
        CompletableFuture<Void> completableFuture1 = CompletableFuture.runAsync(() -> {
            try {
                jobLauncher.run(undrugDetailJob, jobParameters);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, executor);
        completableFutureList.add(completableFuture1);
        CompletableFuture<Void> completableFuture2 = CompletableFuture.runAsync(() -> {
            try {
                jobLauncher.run(rEmployeeJob, jobParameters);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, executor);
        completableFutureList.add(completableFuture2);
        CompletableFuture<Void> completableFuture3 = CompletableFuture.runAsync(() -> {
            try {
                jobLauncher.run(rDepartmentJob, jobParameters);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, executor);
        completableFutureList.add(completableFuture3);

        CompletableFuture<Void> completableFuture4 = CompletableFuture.runAsync(() -> {
            try {
                jobLauncher.run(cpoeProjectDischargeExeJob, jobParameters);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, executor);
        completableFutureList.add(completableFuture4);

        CompletableFuture<Void> completableFuture5 = CompletableFuture.runAsync(() -> {
            try {
                jobLauncher.run(OpRecordJob, jobParameters);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, executor);
        completableFutureList.add(completableFuture5);

        CompletableFuture<Void> completableFuture6 = CompletableFuture.runAsync(() -> {
            try {
                jobLauncher.run(opApplyJob, jobParameters);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, executor);
        completableFutureList.add(completableFuture6);
        CompletableFuture<Void> completableFuture7 = CompletableFuture.runAsync(() -> {
            try {
                jobLauncher.run(mrmsdymrJob, jobParameters);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, executor);
        completableFutureList.add(completableFuture7);



        int size = completableFutureList.size();
        CompletableFuture[] array = new CompletableFuture[size];
        for (int i = 0;i<size;i++){
            array[i] = completableFutureList.get(i);
        }
        CompletableFuture.allOf(array).join();





    }

     public    DateDTO  updateInformation(DateDTO dto){
         DateDTO dateDTO = new DateDTO();

         AssessmentCycle assessmentCycle = assessmentCycleMapper.selectById(dto.getId());
         String startTime = assessmentCycle.getStartDate().toString();
         String endTime = assessmentCycle.getEndDate().toString();
         String startDate = TimeUtils.getLocalDateStartString(assessmentCycle.getStartDate());
         String endDate = TimeUtils.getLocalDateEndString(assessmentCycle.getEndDate());
         String start = TimeUtils.getLocalDateToString(assessmentCycle.getStartDate());
         String end = TimeUtils.getLocalDateToString(assessmentCycle.getEndDate());
//         String  splitTableName =assessmentCycle.getYear().toString()+assessmentCycle.getTimes().toString();
         dateDTO.setStartDate(startDate);
         dateDTO.setEndDate(endDate);
         dateDTO.setStart(start);
         dateDTO.setEnd(end);
         dateDTO.setStartTime(startTime);
         dateDTO.setEndTime(endTime);
         dateDTO.setPeriod(dto.getPeriod());
         return   dateDTO;

     }




}
